package tr.edu.ege.kipler.satisfiability.profile;

import tr.edu.ege.kipler.satisfiability.Reasoner;
import tr.edu.ege.kipler.satisfiability.completion.CompletionStrategy;
import tr.edu.ege.kipler.satisfiability.completion.SHIQModifiedIndividualBasedCompletionStrategy;
import tr.edu.ege.kipler.satisfiability.completion.SHIQBasicCompletionStrategy;
import tr.edu.ege.kipler.satisfiability.container.creational.WcsFactory;
import tr.edu.ege.kipler.satisfiability.container.creational.ContainerType;
import tr.edu.ege.kipler.satisfiability.syntactical.SHIQPreprocessingStrategy;
import tr.edu.ege.kipler.satisfiability.syntactical.SyntacticalProcessingStrategy;

/**
 * 
 * @author İnanç Seylan
 *
 */
public class SHIQReasoningProfile implements ReasoningProfile {

	private CompletionStrategy completionStrategy;

	private SyntacticalProcessingStrategy preprocessingStrategy;

	private boolean modifiedIndividualList, logging, backjumping;

	private Reasoner reasoner;

	private ContainerType wcsType;

	public SHIQReasoningProfile(Reasoner reasoner) {
		this.reasoner = reasoner;
//		completionStrategy = new SHIQBasicCompletionStrategy(reasoner);
//		wcsType = ContainerType.SHIQ_BASIC;
		toggleModifiedIndividualList();
		preprocessingStrategy = new SHIQPreprocessingStrategy(reasoner);
		backjumping = true;
	}

	public CompletionStrategy getCompletionStrategy() {
		return completionStrategy;
	}

	public SyntacticalProcessingStrategy getPreprocessingStrategy() {
		return preprocessingStrategy;
	}

	public WcsFactory getWcsFactory() {
		return WcsFactory.getFactory(wcsType);
	}

	public String getIdentifier() {
		return "SHIQ";
	}

	public SHIQReasoningProfile toggleLogging() {
		logging = !logging;
		return this;
	}

	public boolean isLoggingEnabled() {
		return logging;
	}

	public boolean isBackjumpingEnabled() {
		return backjumping;
	}

	public boolean isModifiedIndividualListEnabled() {
		return modifiedIndividualList;
	}

	public SHIQReasoningProfile toggleBackjumping() {
		backjumping = !backjumping;
		return this;
	}

	public SHIQReasoningProfile toggleModifiedIndividualList() {
		modifiedIndividualList = !modifiedIndividualList;
		if (modifiedIndividualList) {
			completionStrategy = new SHIQModifiedIndividualBasedCompletionStrategy(
					reasoner);
			wcsType = ContainerType.SHIQ_MODIFIED_INDIVIDUAL;
		} else {
			completionStrategy = new SHIQBasicCompletionStrategy(reasoner);
			wcsType = ContainerType.SHIQ_BASIC;
		}
		return this;
	}

}
